package com.systop.ltbook.webapp.article;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.systop.cms.CmsConstants;
import com.systop.cms.article.service.ArticleManager;
import com.systop.cms.model.Articles;
import com.systop.cms.utils.PageUtil;
import com.systop.core.dao.support.Page;
import com.systop.core.webapp.struts2.action.DefaultCrudAction;

@SuppressWarnings({ "serial"})
@Controller
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class LtArticleAction extends DefaultCrudAction<Articles, ArticleManager> {

	//栏目ID
	private Integer catalogId;
	
	/**
	 * 查看文章
	 * @return
	 */
	public String list() {
		Page page = PageUtil.getPage(getPageNo(), getPageSize());
		String hql = "from Articles a where a.catalog.id=? and a.audited=? order by a.onTop DESC ,serialNo ,createTime DESC";
		page = getManager().pageQuery(page, hql, new Object[]{catalogId, CmsConstants.Y});
		restorePageData(page);
		return "list";
	}
	
	public void setCatalogId(Integer catalogId) {
		this.catalogId = catalogId;
	}
	
}
